﻿using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace DevConHelper {
	partial class MainForm : Form {
		public MainForm() {
			InitializeComponent();
		}

		private void MainForm_Load(object sender, EventArgs e) {
			//if (Settings.Default.Bounds.Height == 0)
			//    StartPosition = FormStartPosition.WindowsDefaultLocation;
			//else {
			//    Bounds = Settings.Default.Bounds;
			//}
			//toolStripButtonPinAot.Checked = Settings.Default.AOT;
		}

		private void toolStripButtonPinAot_CheckedChanged(object sender, EventArgs e) {
			TopMost = toolStripButtonPinAot.Checked;
			MainForm_OptionChanged(null, null);
		}

		private void timerSaveOptions_Tick(object sender, EventArgs e) {
			timerSaveOptions.Stop();
			Save();
		}

		private void Save() {
			//Settings.Default.AOT = toolStripButtonPinAot.Checked;
			//Settings.Default.Bounds = Bounds;
			//Settings.Default.Save();
		}

		private void MainForm_OptionChanged(object sender, EventArgs e) {
			timerSaveOptions.Start();
		}

		private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
			if (e.CloseReason == CloseReason.UserClosing) {
				e.Cancel = true;
				Hide();
			}
		}

		private void rtb_LinkClicked(object sender, LinkClickedEventArgs e) {
			var s = e.LinkText.Replace("file://", "").Replace("/","\\");
			s=s[0]+":"+s.Substring(1);
			Process.Start("devenv",s);
		}

		private void rtb_TextChanged(object sender, EventArgs e) {
			rtb.SelectionStart = rtb.Text.Length;
			rtb.ScrollToCaret();
		}



	}
}
